<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>1-100之间各种和</title>
</head>
<body>
    <script>
        // 1.1~100之间所有整数的累加和 sum
        var sum1 = 0;
        for (i = 1; i <= 100; i++) {
            sum1 += i;
        }
        console.log(sum1);
        // 2.1~100之间所有数的平均值 average
        var sum2 = 0;
        var average = 0;
        for (i = 1; i <= 100; i++) {
            sum2 += i;
        }
        average =  sum2 % 100;
        console.log(average);
        // 3.1~100之间所有偶数 even 和奇数 odd 的和 
        var even = 0;
        var odd = 0;
        for (i = 1; i <= 100; i++) {
            if (i % 2 == 0) {
                even = even + i;
            } else {
                odd = odd + i;
            }
        }
        console.log(even);
        console.log(odd);
        // 4.1~100之间能被3整除的数之和 result
        var sum3 = 0;
        for (i = 1; i <= 100; i++) {
            if (i % 3 == 0) {
                sum3 += i;
            }
            
        }
        console.log(sum3);
    </script>
</body>
</html>